package com.java110.mall.shop.smo.impl;


import com.java110.mall.shop.dao.IShopSettingKeyServiceDao;
import com.java110.intf.shop.IShopSettingKeyInnerServiceSMO;
import com.java110.dto.shop.ShopSettingKeyDto;
import com.java110.po.shop.ShopSettingKeyPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 配置信息内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopSettingKeyInnerServiceSMOImpl extends BaseServiceSMO implements IShopSettingKeyInnerServiceSMO {

    @Autowired
    private IShopSettingKeyServiceDao shopSettingKeyServiceDaoImpl;


    @Override
    public int saveShopSettingKey(@RequestBody  ShopSettingKeyPo shopSettingKeyPo) {
        int saveFlag = 1;
        shopSettingKeyServiceDaoImpl.saveShopSettingKeyInfo(BeanConvertUtil.beanCovertMap(shopSettingKeyPo));
        return saveFlag;
    }

     @Override
    public int updateShopSettingKey(@RequestBody  ShopSettingKeyPo shopSettingKeyPo) {
        int saveFlag = 1;
         shopSettingKeyServiceDaoImpl.updateShopSettingKeyInfo(BeanConvertUtil.beanCovertMap(shopSettingKeyPo));
        return saveFlag;
    }

     @Override
    public int deleteShopSettingKey(@RequestBody  ShopSettingKeyPo shopSettingKeyPo) {
        int saveFlag = 1;
        shopSettingKeyPo.setStatusCd("1");
        shopSettingKeyServiceDaoImpl.updateShopSettingKeyInfo(BeanConvertUtil.beanCovertMap(shopSettingKeyPo));
        return saveFlag;
    }

    @Override
    public List<ShopSettingKeyDto> queryShopSettingKeys(@RequestBody  ShopSettingKeyDto shopSettingKeyDto) {

        //校验是否传了 分页信息

        int page = shopSettingKeyDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopSettingKeyDto.setPage((page - 1) * shopSettingKeyDto.getRow());
        }

        List<ShopSettingKeyDto> shopSettingKeys = BeanConvertUtil.covertBeanList(shopSettingKeyServiceDaoImpl.getShopSettingKeyInfo(BeanConvertUtil.beanCovertMap(shopSettingKeyDto)), ShopSettingKeyDto.class);

        return shopSettingKeys;
    }


    @Override
    public int queryShopSettingKeysCount(@RequestBody ShopSettingKeyDto shopSettingKeyDto) {
        return shopSettingKeyServiceDaoImpl.queryShopSettingKeysCount(BeanConvertUtil.beanCovertMap(shopSettingKeyDto));    }

    public IShopSettingKeyServiceDao getShopSettingKeyServiceDaoImpl() {
        return shopSettingKeyServiceDaoImpl;
    }

    public void setShopSettingKeyServiceDaoImpl(IShopSettingKeyServiceDao shopSettingKeyServiceDaoImpl) {
        this.shopSettingKeyServiceDaoImpl = shopSettingKeyServiceDaoImpl;
    }
}
